<!DOCTYPE html>
<html>
<head>
    <title>让生活更美好 </title>
    <link href="./static/css/login.css" rel='stylesheet' type='text/css' />
    <script src="./static/plugins/jquery/jquery-2.1.4.min.js"></script>
    <script src="./static/plugins/layer/layer.js"></script>
    <script src="./static/js/common.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>

<h1>注册 聊天室  </h1>
<div class="login-form">
    <div class="head-info">
        <label class="lbl-1"></label>
        <label class="lbl-2"></label>
        <label class="lbl-3"></label>
    </div>
    <div class="clear"> </div>
    <div class="avtar"><img src="./static/images/avtar.png" /></div>
    <div class="key">
        <input type="text" id="mobile" name="mobile" placeholder="请输入手机号" >
    </div>
    <div class="key">
        <input type="text" id="name" name="name" placeholder="姓名" >
    </div>
    <div class="key">
        <input type="password" id="password" name="password" placeholder="请输入密码">
    </div>
    <div class="signin">
        <input type="submit" id="register" value="注册" >
    </div>
</div>

<script>
    $(function(){
        $('#mobile,#password').change(function(){
            $('#register').attr('value','注册').css('background','#3ea751');
        });
    });
    /**
     * check the login form before user login.
     * @returns {boolean}
     */
    $('#register').click(function(){
        var mobile = $('#mobile').val();
        var password = $('#password').val();
        var name = $('#name').val();
        if(isNull(mobile) && isNull(password)){
            $('#register').attr('value','手机号或密码不能为空').css('background','red');
            return false;
        }
        if(isNull(mobile)){
            $('#register').attr('value','请输手机号').css('background','red');
            return false;
        }

        if(isNull(password)){
            $('#register').attr('value','请输入密码').css('background','red');
            return false;
        }
        var userData = getAjax('member/register',{"mobile":mobile,"password":password,"name":name});
        if(userData.code != 200){
            $('#register').attr('value',userData.msg).css('background','red');
        }else{
            $('#register').attr('value',userData.msg).css('background','red');

            setInterval(function () {
                window.location.href = "/Public/login.html";
            },2000);


        }
    });
</script>
</body>
</html>